﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using VSLT_ReportingEngine;

namespace ExcelAddinDialogBoxes
{
    /// <summary>
    /// Interaction logic for GetRuns.xaml
    /// </summary>
    public partial class GetRuns : UserControl
    {
        public DataTable runsListDataTable { get; private set; }
        public DataTable resultsDataTable { get; private set; }        
        public static string reportingEngineVersion = "6.0.0.1 Beta";
        
        private ReportingEngine re;

        public GetRuns()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            runsListDataTable = new DataTable();
            resultsDataTable = new DataTable();
            re = new ReportingEngine(@"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=LoadTest2010;Integrated Security=True",reportingEngineVersion);
        }

        private void dgMainResults_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }

        private void btnGetRuns_Click(object sender, RoutedEventArgs e)
        {
            runsListDataTable = re.GetListOfCompletedRuns();

            dgMainResults.ItemsSource = runsListDataTable.AsDataView();
        }

        private void btnProcessRuns_Click(object sender, RoutedEventArgs e)
        {
            //Add code here to get the main result set of the highlighted items
        }

        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            runsListDataTable.Clear();
            resultsDataTable.Clear();
        }
    }
}
